package ExceptionAssertAndLog.stackTrace;

import java.util.Scanner;

public class StackTraceTest {
    public static int factoria(int n){
        System.out.println("factorial("+n+"):");
        Throwable t=new Throwable();
        StackTraceElement[] frames=t.getStackTrace();
        for(StackTraceElement stackTraceElement:frames){
            System.out.println(stackTraceElement);
        }

        int r;
        if(n<=1) r=1;
        else r=n*factoria(n-1);
        System.out.println("return "+r);
        return  r;
    }

    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        System.out.println("Enter n: ");
        int n=in.nextInt();
        factoria(n);
    }
}
